package org.rsbot.script.internal.wrappers;

import org.rsbot.client.Node;

public class HashTable
{
  private org.rsbot.client.HashTable nc;
  private Node current;
  private int c_index = 0;

  public HashTable(org.rsbot.client.HashTable paramHashTable) {
    this.nc = paramHashTable;
  }

  public Node getFirst() {
    this.c_index = 0;
    return getNext();
  }

  public Node getNext()
  {
    Node localNode;
    if ((this.c_index > 0) && (this.nc.getBuckets()[(this.c_index - 1)] != this.current)) {
      localNode = this.current;
      this.current = localNode.getPrevious();
      return localNode;
    }
    while (this.c_index < this.nc.getBuckets().length) {
      localNode = this.nc.getBuckets()[(this.c_index++)].getPrevious();
      if (this.nc.getBuckets()[(this.c_index - 1)] != localNode) {
        this.current = localNode.getPrevious();
        return localNode;
      }
    }
    return null;
  }
}